﻿using System;
using Microsoft.Practices.Unity;

namespace TestByWire
{
	internal class DoNotStub
	{
		public DoNotStub(Type type, string instanceName)
		{
			if (type == null) throw new ArgumentNullException("type");
			_type = type;
			_instanceName = instanceName;
		}

		public override bool Equals(object obj)
		{
			if (obj == null)
				return false;
			if (GetType() != obj.GetType())
				return false;
			var other = (DoNotStub) obj;
			if (!Equals(_type, other._type))
				return false;
			return Equals(_instanceName, other._instanceName);
		}

		public override int GetHashCode()
		{
			return _type.GetHashCode();
		}

		private readonly Type _type;
		private readonly String _instanceName;

		public bool IsInContainer(IUnityContainer container)
		{
			return container.IsRegistered(_type, _instanceName);
		}
	}
}
